<%@ include file="/taglibs.jsp"%>
<jsp:directive.page import="java.util.Random"/>
<jsp:directive.page import="java.util.Date"/>
<jsp:directive.page import="java.util.Set"/>
<jsp:directive.page import="com.winterwar.base.Event"/>
<jsp:directive.page import="com.winterwar.base.Slot"/>
<jsp:directive.page import="com.winterwar.base.Convention"/>
<jsp:directive.page import="com.winterwar.base.User"/>
<jsp:directive.page import="com.winterwar.base.Registration"/>
<jsp:directive.page import="java.text.NumberFormat"/>

<%if(session.getAttribute("randFormID") == null){
	Random gen = new Random(new Date().getTime());
	session.setAttribute("randFormID", gen.nextInt() + "");
}
	Registration reg = (Registration) request.getAttribute("registration");
	double costOffset = reg.getCostOffset();
	double cost = reg.getCost();
	
	double total = cost - costOffset;
	double toPay = cost - costOffset;
	NumberFormat nf = NumberFormat.getCurrencyInstance();
	
	toPay = toPay + .31;
	toPay = toPay / 0.971;
	toPay = toPay * 100;
	toPay = Math.round(toPay);
	toPay = toPay/100;
%>

<title>Winter War - Confirm Registration</title>

<p> Thank you for deciding to register with Winter War!  Please take this time to confirm your registration information below.  If everything is correct, just press "Submit" to continue with the registration process!</p>

<hr>
<center>
<table>
	<tr>
		<th>Registrant Name</th> <td colspan="3">${user.firstName } ${user.lastName }</td>
	</tr><tr>
		<th>Address</th> <td colspan="3">${user.address1 }</td>
	</tr><tr>
		<th>City/State/Postal Code</th> <td colspan="3">${user.city }, ${user.state } ${user.zipCode }</td>
	</tr><tr>
		<th>Contact Info</th> <td colspan="3">${user.email } ${user.phoneNumber }</td>
	</tr>
	<tr><td colspan="4"><hr></td></tr>
	<tr>
		<th><bean:message key="registration.type"/>: </th>
		<c:choose>
			<c:when test="${registration.type == '1' }">
				<td>Single Day</td>
				<th><bean:message key="registration.dayRegistered"/>: </th>
				<td>
					<c:choose>
						<c:when test="${registration.dayRegistered == '1' }">Friday</c:when>
						<c:when test="${registration.dayRegistered == '2' }">Saturday</c:when>
						<c:when test="${registration.dayRegistered == '3' }">Sunday</c:when>
					</c:choose>
				</td>
			</c:when>
			<c:when test="${registration.type == 2 }">
				<td colspan="3">Weekend</td>
			</c:when>
			<c:when test="${registration.type == 3 }">
				<td colspan="3">ASL Weekend</td>
			</c:when>
		</c:choose>
	</tr>
	<tr><th>Events Selected:</th></tr>
	<c:forEach var="regEvent" items="${events}">
		<tr>
			<td colspan="4">${regEvent.slotName } : ${regEvent.eventName}</td>
		</tr>
	</c:forEach>
	<tr><td colspan="4"><hr></td></tr>
	<tr>
		<th>Sub-Total: </th>
		<td colspan="3"><%=nf.format(cost) %></td>
	</tr>
	<tr>
		<th>Judges Discount:</th>
		<td colspan="3"><%=nf.format(costOffset) %></td>
	</tr>
	<tr>
		<th>Amount Owed:</th>
		<td colspan="3"><%=nf.format(total) %></td>
	</tr>
</table>


<html:form action="/registration">
	<input type="hidden" name="method" value="register"/>
	<input type="hidden" name="formID" value="<%=session.getAttribute("randFormID") %>"/>
	<html:hidden property="registration.conID"/>
	<html:hidden property="registration.userID"/>
	<html:hidden property="registration.cost"/>
	<html:hidden property="registration.costOffset"/>
	<html:hidden property="registration.status"/>
	<html:hidden property="registration.regID"/>
	<html:hidden property="registration.type"/>
	<html:hidden property="registration.dayRegistered"/>
	<c:forEach var="regEvent" items="${events}">
			<input type="hidden" name="events" value="${regEvent.eventID }" />
	</c:forEach>
	<html:submit>Finalize Registration</html:submit>
</html:form>
